/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GuiInyeccionErrores.java
 *
 * Created on 04-dic-2010, 22:16:52
 */

package interfaz;

/**
 *
 * @author Rubén Tarancon, Felipe Serrano
 */
public class GUIInyeccionErrores extends javax.swing.JDialog {

    private int xInicial, yInicial, xFinal, yFinal;

    /** Creates new form GuiInyeccionErrores */
    public GUIInyeccionErrores(java.awt.Frame parent, boolean modal, int[] limites) {
        super(parent, modal);
        initComponents();
        TxtInfo.setText("***La región máxima reservada comprende los slices desde ("+limites[0]+","+limites[1]+") hasta el ("+limites[2]+","+limites[3]+")***");
    }

    public int getXInicial(){return xInicial;}
    public int getYInicial(){return yInicial;}
    public int getXFinal(){return xFinal;}
    public int getYFinal(){return yFinal;}

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnOk = new javax.swing.JButton();
        TxtXInicial = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        txtNSliceX = new javax.swing.JLabel();
        txtNSliceY = new javax.swing.JLabel();
        TxtYInicial = new javax.swing.JTextField();
        TxtXFinal = new javax.swing.JTextField();
        TxtYFinal = new javax.swing.JTextField();
        TxtInfo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Localizacion del circuito");

        btnOk.setText("Ok");
        btnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkActionPerformed(evt);
            }
        });

        TxtXInicial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtXInicialActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("SLICES");

        txtNSliceX.setText("Esquina inferior izquierda:");

        txtNSliceY.setText("Esquina superior derecha:");

        TxtYInicial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtYInicialActionPerformed(evt);
            }
        });

        TxtXFinal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtXFinalActionPerformed(evt);
            }
        });

        TxtYFinal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtYFinalActionPerformed(evt);
            }
        });

        TxtInfo.setText("***La región máxima reservada comprende los slices desde (-,-) hasta el (-,-)***");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnOk)
                        .addGap(94, 94, 94))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(txtNSliceY, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(TxtXFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(txtNSliceX, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(TxtXInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TxtYInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(TxtYFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(62, 62, 62))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(200, 200, 200))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TxtInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TxtInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNSliceX)
                    .addComponent(TxtXInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TxtYInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNSliceY)
                    .addComponent(TxtXFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TxtYFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(btnOk)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
        try{
            this.xInicial = Integer.parseInt(TxtXInicial.getText());
        }catch(NumberFormatException e){
            this.xInicial=-1;
        }
        try{
            this.yInicial = Integer.parseInt(TxtYInicial.getText());
        }catch(NumberFormatException e){
            this.yInicial=-1;
        }
        try{
            this.xFinal = Integer.parseInt(TxtXFinal.getText());
        }catch(NumberFormatException e){
            this.xFinal=-1;
        }
        try{
            this.yFinal = Integer.parseInt(TxtYFinal.getText());
        }catch(NumberFormatException e){
            this.yFinal=-1;
        }
        this.dispose();
        
    }//GEN-LAST:event_btnOkActionPerformed

    private void TxtXInicialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtXInicialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtXInicialActionPerformed

    private void TxtYInicialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtYInicialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtYInicialActionPerformed

    private void TxtXFinalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtXFinalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtXFinalActionPerformed

    private void TxtYFinalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtYFinalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtYFinalActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel TxtInfo;
    private javax.swing.JTextField TxtXFinal;
    private javax.swing.JTextField TxtXInicial;
    private javax.swing.JTextField TxtYFinal;
    private javax.swing.JTextField TxtYInicial;
    private javax.swing.JButton btnOk;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel txtNSliceX;
    private javax.swing.JLabel txtNSliceY;
    // End of variables declaration//GEN-END:variables

}
